﻿using TouchSocket.Core;
using TouchSocket.Sockets;

var udpService = new UdpSession();
udpService.Received = (c,e) =>
{
    var bytes = e.ByteBlock.ToArray();
    string hex = BitConverter.ToString(bytes).Replace("-", " ");
    Console.WriteLine(hex);
    Console.WriteLine(e.ByteBlock);
    return EasyTask.CompletedTask;
};
udpService.Setup(new TouchSocketConfig()
    .SetBindIPHost(new IPHost(50789)));
try
{
    udpService.Start();
}
catch (Exception e)
{
    Console.WriteLine(e);
}
Console.ReadKey();